// Extend.js (http://code.google.com/p/extendjs/)
// Copyright 2010 Shumpei Shiraishi All rights reserved.
// Licensed under the MIT license.

(function(_global) {
    X.extend("Date", function(value) {
	return value instanceof Date;
    });
    X.Date.extend({
	isDate: function() {
	    return true;
	},
	toISOString: function() {
	    return this.getUTCFullYear() + '-' +
		X(this.getUTCMonth() + 1).padLeft("0", 2) + '-' +
		this.getUTCDateX().padLeft("0", 2) + 'T' +
		this.getUTCHoursX().padLeft("0", 2) + ':' +
		this.getUTCMinutesX().padLeft("0", 2) + ':' +
		this.getUTCSecondsX().padLeft("0", 2) + '.' +
		this.getUTFMillisecondsX().padLeft("0", 3) + 'Z';
	},
	isLeapYear: function() {
	    var year = this.__val.getFullYear();
	    return !(year%400) || (!(year%4) && !!(year%100)); // Boolean
	}
    });
    var NATIVE_METHODS_DATE = [
	"toString", "toDateString", "toTimeString", "toLocaleString", "toLocaleDateString",
	"toLocaleTimeString", "valueOf", "getTime", "getFullYear", "getUTCFullYear",
	"getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay",
	"getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds",
	"getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "getTimezoneOffset",
	"setTime", "setFullYear", "setUTCFullYear",
	"setMonth", "setUTCMonth", "setDate", "setUTCDate", "setDay", "setUTCDay",
	"setHours", "setUTCHours", "setMinutes", "setUTCMinutes", "setSeconds",
	"setUTCSeconds", "setMilliseconds", "setUTCMilliseconds",
	"toUTCString", "toISOString", "toJSON"
    ];
    X.Date.mixin(Date.prototype, NATIVE_METHODS_DATE);
})(this);
